<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>商铺登记</title>
  <link rel="shortcut icon" href="商.png" type="image/x-icon">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="component/elementUI/index.css">
  <link rel="stylesheet" href="style/wangeditor.css">
  <link rel="stylesheet" href="style/index.css">
  <style>
    h1,
    h3 {
      text-align: center;
    }

    h3 {
      color: cornflowerblue;
    }

    .el-tabs__content {
      overflow: visible;
    }

    .el-tabs__nav-scroll {
      position: relative;
    }
  </style>

<body>
  <div id="app" v-cloak>
    <div
      style="display: flex; flex-direction: column; justify-content: center; align-items: center;height: calc(100vh - 40px) ;">
      <div class="sahng">
        <h1>社区营销欢迎你</h1>
        <h3>请登记店铺信息</h3>
      </div>
      <div class="kap">
        <el-tabs type="border-card">
          <span style="position: absolute; right: 10px; top: -40px; z-index: 1;">
            <el-button type="text" @click="window.history.back()">返回</el-button>
          </span>
          <el-tab-pane label="注册申请">
            <div style="display: flex;">
              <div style="width: 100%;">
                <el-form :label-position="labelPosition" label-width="80px" ref="contract" :model="form">
                  <el-form-item label="执照编码:">
                    <el-input v-model="form.Store_SerialNumber" placeholder="请输入执照编号"></el-input>
                  </el-form-item>
                  <el-form-item label="店铺名称:">
                    <el-input v-model="form.Store_Name" placeholder="请输入店铺名称"></el-input>
                  </el-form-item>
                  <el-form-item label="店铺地址:">
                    <el-cascader v-model.trim="value" filterable :options="city" placeholder="请输入店铺地址"></el-cascader>
                  </el-form-item>
                  <el-form-item label="详细地址:">
                    <el-input v-model="form.Store_Address" placeholder="请输入详细地址"></el-input>
                  </el-form-item>
                  <el-form-item label="联系人:">
                    <el-input v-model="form.ID_Name" placeholder="请输入联系人"></el-input>
                  </el-form-item>
                  <el-form-item label="联系方式:">
                    <el-input v-model="form.User_Number" placeholder="请输入联系方式"></el-input>
                  </el-form-item>
                  <el-form-item label="登录密码:">
                    <el-input v-model="form.Pass_Word" placeholder="请输入登录密码"></el-input>
                  </el-form-item>
                </el-form>
              </div>
              <div style="display: flex;flex-shrink: 0; flex-direction: column; align-items: center;  width: 200px;">
                <div class="table_titel">
                  <div class="titel">营业执照</div>
                </div>
                <yl-upload unslider base64 v-model.trim="form.Business_License"></yl-upload>
              </div>
            </div>
            <div style="width: 100%; display: flex;justify-content: center;margin-bottom: 20px;">
              <el-button type="primary" style="margin:0 auto; width: 80%;" @click="submit('contract')">申请</el-button>
            </div>
          </el-tab-pane>
        </el-tabs>
      </div>
    </div>
    <!-- <el-dialog title="申请通知" :visible.sync="waitingDialogVisible" width="13%" center>
      <el-result class="cheng" icon="success" title="申请成功，请等待平台审核" subTitle="请根据提示进行操作">
      </el-result>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="handleWaitingClose" class="tongq">确 定</el-button>
      </span>
    </el-dialog>

    <el-dialog title="审核通知" :visible.sync="auditNotificationVisible" width="13%" center>
      <el-result class="cheng" icon="success" title="恭喜你审核通过了" subTitle="请根据提示进行操作">
      </el-result>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="handleAuditClose" class="tongq">确 定</el-button>
      </span>
    </el-dialog> -->
  </div>
</body>
<script type="text/javascript" src="utils/wangeditor.js"></script>
<script type="text/javascript" src="utils/jquery.min.js"></script>
<script type="text/javascript" src="utils/jquery.cookie.js"></script>
<script type="text/javascript" src="utils/vue.min.js"></script>
<script type="text/javascript" src="utils/vuex.min.js"></script>
<script type="text/javascript" src="component/elementUI/index.js"></script>
<script type="text/javascript" src="component/component.js"></script>
<script type="text/javascript" src="config/config.js"></script>
<script type="text/javascript" src="utils/FileSaver.min.js"></script>
<script type="text/javascript" src="utils/FileSaver.js"></script>
<script type="text/javascript" src="utils/xlsx.full.min.js"></script>
<script type="text/javascript" src="utils/xlsx.core.min.js"></script>
<script type="text/javascript" src="utils/compressor.js"></script>
<script type="text/javascript" src="utils/ID_Validity.js"></script>
<script type="text/javascript" src="utils/utils.js"></script>
<script>
  new Vue({
    el: '#app',
    data() {
      return {
        waitingDialogVisible: false, // 控制等待审核对话框的显示
        auditNotificationVisible: false, // 控制审核通知对话框的显示
        activeStep: 1,
        fullscreenLoading: false,
        imageUrl: '',
        labelPosition: 'right',
        form: {
          Store_SerialNumber: '',
          Store_Name: '',
          Opened_Date: '',
          Closed_Date: '',
          Business_License: '',
          ProvinceNumber: '',
          CityNumber: '',
          CountyNumber: '',
          Store_Address: '',
          Store_Type: '',
          Row_Status: '2',
          User_Number: '',
          ID_Name: '',//表名
          Pass_Word: 'Aa123456',//描述
        },
        city: [],
        value: [],
        add: [],
      }
    },
    mounted() {
      this.getData();
    },
    watch: {
      'form.Business_License'(Data) {
        const that = this;
        if (Data) {
          $.ajax({
            url: BASE_URL1 + "/parseBusinessLicenseAction",
            type: "POST",
            data: { Data },
            success: function (data) {
              that.form.Store_SerialNumber = data.tax_number;
              that.form.Store_Name = data.name;
            },
            dataType: "json"
          })
        }else{
          that.form.Store_SerialNumber = '';
          that.form.Store_Name = '';
        }
      }
    },
    methods: {
      getData() {
        const that = this;
        $.ajax({
          url: "utils/city.json",
          type: "GET",
          success: function (data) {
            that.city = data
          },
          dataType: "json"
        })
      },
      submit(formName) {
        const that = this;
        this.$refs[formName].validate((valid) => {
          if (valid) {
            this.form.ProvinceNumber = this.value[0];
            this.form.CityNumber = this.value[1];
            this.form.CountyNumber = this.value[2];
            this.form.Opened_Date = getYMDHMSDate();
            $.ajax({
              headers: requestHeaders(),
              url: `${BASE_URL2}/generalBusiness/generalSave`,
              type: 'POST',
              data: {
                Data: JSON.stringify({
                  Add: {
                    business_store_info: [that.form],
                  }
                })
              },
              success: function (res) {
                if (res.Status === 'success') {
                  let base_system_user_info = [{
                    User_Number: that.form.User_Number,
                    Pass_Word: that.form.Pass_Word,
                    ID_Name: that.form.ID_Name,
                    Image: '',
                    Name: that.form.Name,
                    Sex: '0',
                    Mail: '',
                    Creation_Datetime: getYMDHMSDate(),
                    Children: {
                      base_system_user_role: [{
                        System_User_Role_SerialNumber: '',
                        User_Number: that.form.User_Number,
                        Role_SerialNumber: 'store',
                        Other_SerialNumber: res.Data
                      }]
                    }
                  }];
                  $.ajax({
                    headers: requestHeaders(),
                    url: `${BASE_URL2}/generalBusiness/generalSave`,
                    type: 'POST',
                    data: {
                      Data: JSON.stringify({
                        Add: {
                          base_system_user_info,
                        }
                      })
                    },
                    success: function (res) {
                      if (res.Status === 'success') {
                        that.$message.success("提交成功,待平台审核")
                        window.history.go(-1)
                      } else {
                        that.$message.error("提交失败，请稍后再试")
                      }
                    },
                    complete: function (XMLHttpRequest) {
                      that.loading = false
                      requestPretreatment(XMLHttpRequest);//config/config.js 响应预检
                    },
                    dataType: "json"
                  })
                } else {
                  that.$message.error("提交失败，请稍后再试")
                }
              },
              complete: function (XMLHttpRequest) {
                that.loading = false
                requestPretreatment(XMLHttpRequest);//config/config.js 响应预检
              },
              dataType: "json"
            })
          }
        })
      }
    }
  })
</script>

</html>